function formatTime(val) {
    var dateObj = new Date(val*1000);
    var UnixTimeToDate = dateObj.getFullYear() + '-' + addZero(dateObj.getMonth() + 1) + '-' + addZero(dateObj.getDate()) + ' ' + addZero(dateObj.getHours()) + ':' + addZero(dateObj.getMinutes()) + ':' + addZero(dateObj.getSeconds());
    document.write(UnixTimeToDate);
}

function formatDate(val) {
    var dateObj = new Date(val*1000);
    var UnixTimeToDate = dateObj.getFullYear() + '-' + addZero(dateObj.getMonth() + 1) + '-' + addZero(dateObj.getDate());
    document.write(UnixTimeToDate);
}


function addZero(i) {
    return (i < 10 ? "0" : "") + i;
}

function setCheckBoxValue(vals, name) {
    if (vals == "") {
        if (name != "platform") {
            $("input[id='" + name + "_0']").each(function () {
                this.checked = true;
            });
        }
    }
    else if (vals == "0") {
        $("input[name='" + name + "']").each(function () {
            this.checked = true;
        });
    } else {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            $("#" + name + "_" + val[i]).attr("checked", true);
            if (val[i] == 1 && name == 'feature') {//孕期用户，禁止经期可选
                $("input[name='period']").each(function () {
                    $("#period_" + this.value).attr("checked", false);
                    $("#period_" + this.value).attr("disabled", "disabled");
                });
            }
        }
    }
}

function setCheckBoxValueNoDefault(vals, name) {
    if (vals == "" || vals == 0) {
        if (name != "platform") {
            $("input[id='" + name + "_0']").each(function () {
                this.checked = true;
            });
        }
    } else {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            $("#" + name + "_" + val[i]).attr("checked", true);
            if (val[i] == 1 && name == 'feature') {//孕期用户，禁止经期可选
                $("input[name='period']").each(function () {
                    $("#period_" + this.value).attr("checked", false);
                    $("#period_" + this.value).attr("disabled", "disabled");
                });
            }
        }
    }
}


function setCheckBoxValue1(vals, name, id) {
    if (vals == "") {
        $("input[id='" + id + "_0']").each(function () {
            this.checked = true;
        });
    } else if (vals == "0") {
        $("input[name='" + name + "']").each(function () {
            this.checked = true;
        });
    } else {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            $("#" + name + "_" + val[i]).attr("checked", true);
            if (val[i] == 1 && name == 'feature') {//孕期用户，禁止经期可选
                $("input[name='period']").each(function () {
                    $("#period_" + this.value).attr("checked", false);
                    $("#period_" + this.value).attr("disabled", "disabled");
                });
            }
        }
    }
}


function setByIdFormatTime(id, val) {
    if (val != "" && val > 0) {
        var dateObj = new Date(val * 1000);
        var UnixTimeToDate = dateObj.getFullYear() + '-' + addZero(dateObj.getMonth() + 1) + '-' + addZero(dateObj.getDate()) + ' ' + addZero(dateObj.getHours()) + ':' + addZero(dateObj.getMinutes()) + ':' + addZero(dateObj.getSeconds());
        $("#" + id).val(UnixTimeToDate);
    }
}

function setByIdFormatDate(id, val) {
    if (val != "" && val > 0) {
        var dateObj = new Date(val * 1000);
        var UnixTimeToDate = dateObj.getFullYear() + '-' + addZero(dateObj.getMonth() + 1) + '-' + addZero(dateObj.getDate());
        $("#" + id).val(UnixTimeToDate);
    }
}
function setByIdFormatTimeToDate(id, val) {
    if (val != "" && val > 0) {
        var dateObj = new Date(val);
        var UnixTimeToDate = dateObj.getFullYear() + '-' + addZero(dateObj.getMonth() + 1) + '-' + addZero(dateObj.getDate());
        $("#" + id).val(UnixTimeToDate);
    }
}

var targerUserPeriodMap = {};
targerUserPeriodMap["0"] = "全部经期阶段";
targerUserPeriodMap["1"] = "月经期";
targerUserPeriodMap["2"] = "卵泡期";
targerUserPeriodMap["3"] = "排卵期";
targerUserPeriodMap["5"] = "黄体期";

//经期阶段
function formatTargetUserPeriod(vals) {
    if (vals.length != 0) {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            if (i > 0) {
                document.write("，");
            }
            document.write(targerUserPeriodMap[val[i]]);
        }
        document.write("<br>");
    }
}


var usereStatusMap = {};
usereStatusMap["0"] = "全部";
usereStatusMap["1"] = "记经期";
usereStatusMap["2"] = "备孕";
usereStatusMap["3"] = "怀孕中";
usereStatusMap["4"] = "宝妈";
usereStatusMap["5"] = "魔瘦";

//经期阶段
function formatCardStatus(vals) {
    if (vals.length != 0) {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            if (i > 0) {
                document.write("，");
            }
            document.write(usereStatusMap[val[i]]);
        }
        document.write("<br>");
    }
}

var targerUserGroupMap = {};
targerUserGroupMap["0"] = "全部小组";
targerUserGroupMap["1"] = "健康";
targerUserGroupMap["2"] = "孕育";
targerUserGroupMap["3"] = "情感";
targerUserGroupMap["4"] = "美体护肤";
targerUserGroupMap["5"] = "成长";
targerUserGroupMap["6"] = "生活";
targerUserGroupMap["7"] = "杂谈";
targerUserGroupMap["8"] = "购物";
targerUserGroupMap["9"] = "其他";


//目标用户分组
function formatTargetUserGroup(vals) {
    if (vals == '') {
        document.write("全部（包括无小组用户）");
    } else {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            if (i > 0) {
                document.write("，");
            }
            document.write(targerUserGroupMap[val[i]]);
        }
    }
    document.write("<br>");
}

var targerUserAgeMap = {};
targerUserAgeMap["0"] = "全部年龄阶段";
targerUserAgeMap["1"] = "14岁-21岁";
targerUserAgeMap["2"] = "22岁-28岁";
targerUserAgeMap["3"] = "29岁-35岁";
targerUserAgeMap["4"] = "36岁以上";
//目标用户年龄段
function formatTargetUserAge(vals) {
    var val = vals.split(",");
    for (var i = 0; i < val.length; i++) {
        if (i > 0) {
            document.write("，");
        }
        document.write(targerUserAgeMap[val[i]]);
    }
    document.write("<br>");
}


//目标用户特征
var targerUserFeatureMap = {};
targerUserFeatureMap["1"] = "魔瘦用户";
//目标用户年龄段
function formatTargetUserFeature(vals) {
    if (vals != null && vals != "") {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            if (i > 0) {
                document.write("，");
            }
            document.write(targerUserFeatureMap[val[i]]);
        }
        document.write("<br>");
    }
}

var province = {
    "0": "全国地区",
    "1": "北京",
    "2": "天津",
    "3": "河北",
    "4": "山西",
    "5": "内蒙古",
    "6": "辽宁",
    "7": "吉林",
    "8": "黑龙江",
    "9": "上海",
    "10": "江苏",
    "11": "浙江",
    "12": "安徽",
    "13": "福建",
    "14": "江西",
    "15": "山东",
    "16": "河南",
    "17": "湖北",
    "18": "湖南",
    "19": "广东",
    "20": "广西",
    "21": "海南",
    "22": "重庆",
    "23": "四川",
    "24": "贵州",
    "25": "云南",
    "26": "西藏",
    "27": "陕西",
    "28": "甘肃",
    "29": "青海",
    "30": "宁夏",
    "31": "新疆",
    "32": "台湾",
    "33": "香港",
    "34": "澳门"
};

//目标用户年龄段
function formatTargetUserArea(vals) {
    var val = vals.split(",");
    for (var i = 0; i < val.length; i++) {
        if (i > 0) {
            document.write("，");
        }
        document.write(province[val[i]]);
    }
    document.write("<br>");
}
var platfromArry = {"0": "Android", "1": "IOS", "2": "WP"};
//目标用户年龄段
function formatPlatform(vals) {
    var val = vals.split(",");
    for (var i = 0; i < val.length; i++) {
        if (i > 0) {
            document.write("，");
        }
        document.write(platfromArry[val[i]]);
    }
}
var pushStatus = {
    "-1": "删除",
    "0": "新建",
    "1": "正在准备",
    "2": "准备完毕",
    "3": "正在执行（正在推送）",
    "4": "推送完成",
    "5": "任务挂起",
    "6": "准备过程出错",
    "7": "推送失败",
    "8": "取消"
};
//格式化精准push的状态
function formatPushStatus(id) {
    document.write(pushStatus[id]);
}


//姐妹说推荐管理的用户状态sisterPushList
var userStatus = {
    "0": "记经期",
    "1": "备孕",
    "2": "怀孕中",
    "3": "宝妈",
    "4": "魔瘦",
    "5": "通用"
};
function formatUserStatus(vals) {
    var val = vals.split(",");
    if (val.length == 5) {
        document.write("全部");
    } else {
        for (var i = 0; i < val.length; i++) {
            if (i > 0) {
                document.write("，");
            }
            document.write(userStatus[val[i]]);
        }
    }
}
//用户日志管理 用户组
function formatCustomerGroupType(id) {
    document.write(customerGroupType[id]);
}
//话题广告投放目标
var advertTarget = {
    "1": "健康",
    "2": "孕育",
    "3": "情感",
    "4": "美体护肤",
    "5": "成长",
    "6": "生活",
    "7": "杂谈",
    "8": "购物",
    "9": "其他"
};

//用户日志管理 用户组
var customerGroupType = {
    "0": "普通",
    "1": "官方",
    "2": "监控",
    "3": "VIP",
    "10": "美容控",
    "11": "美体狂人",
    "12": "知心MM",
    "13": "占星师",
    "14": "健康达人",
    "15": "超级妈咪",
    "16": "灌水王",
    "17": "关注中",
    "18": "两性",
    "19": "好评达人",
    "20": "优秀组长"
};
//用户日志管理 用户组
function formatAdvertStatus(vals) {
    if (vals != "") {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            if (val[i] != "") {
                if (i >= 1 || i == val.length) {
                    document.write("，");
                }
                document.write(advertTarget[val[i]]);
            }
        }
    }
}
//话题广告投放目标
var advertPlatfromTarget = {
    "android": "Android",
    "iphone": "IOS",
    "windowsphone": "WP"
};
function formatAdvertPlatform(vals) {
    if (vals != "") {
        var val = vals.split(",");
        for (var i = 0; i < val.length; i++) {
            if (val[i] != "") {
                if (i >= 1 || i == val.length) {
                    document.write("，");
                }
                document.write(advertPlatfromTarget[val[i]]);
            }
        }
    } else {
        document.write("Android,IOS,WP");
    }
}




